package com.lianmai.chaincard.adapter;

import android.graphics.Color;
import android.support.annotation.NonNull;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.lianmai.chaincard.R;
import com.lianmai.chaincard.bean.ImageTitleBean;
import com.lianmai.chaincard.widget.DividerGridItemDecoration;
import com.youth.xframe.adapter.XRecyclerViewAdapter;
import com.youth.xframe.adapter.XViewHolder;
import com.youth.xframe.adapter.decoration.DividerDecoration;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: Kite
 * @date: 2018-08-23
 * @description:
 */
public class MineTitleAdapter extends XRecyclerViewAdapter<ImageTitleBean> {

    public MineTitleAdapter(@NonNull RecyclerView mRecyclerView, List<ImageTitleBean> dataLists) {
        super(mRecyclerView, dataLists, R.layout.item_mine_body_view);
    }

    @Override
    protected void bindData(XViewHolder holder, ImageTitleBean data, int position) {
        holder.setImageResource(R.id.iv_icon,data.getImage());
        holder.setText(R.id.tv_name,data.getTitle());
        RecyclerView view = holder.getConvertView().findViewById(R.id.rv_classify);
        MineBodyAdapter bodyAdapter = new MineBodyAdapter(view,data.getList());
        bodyAdapter.getRecyclerView().setLayoutManager(new GridLayoutManager(getContext(),3));
        view.setAdapter(bodyAdapter);
        view.addItemDecoration(new DividerGridItemDecoration(getContext()));
    }

    public class MineBodyAdapter extends XRecyclerViewAdapter<ImageTitleBean>{

        public MineBodyAdapter(@NonNull RecyclerView mRecyclerView, List<ImageTitleBean> dataLists) {
            super(mRecyclerView, dataLists,R.layout.item_home_mine_classify);
        }

        @Override
        protected void bindData(XViewHolder holder, ImageTitleBean data, int position) {
            holder.setImageResource(R.id.iv_icon,data.getImage());
            holder.setText(R.id.tv_title,data.getTitle());
        }

    }

}
